<template>
    <div>
        <button @click='addCount'>通过commit方式改变state</button>
        <button @click='actionAdd'>通过action方式改变state</button>
        <button @click='add()'>通过mapMutations的方式触发mutation</button>
        <p>store中state的count: {{$store.state.count}}</p>
    </div>
</template>
<script>
import { mapMutations } from 'vuex'

export default {
    name: 'mutations',
    methods: {
        addCount() {
            this.$store.commit('increment');
        },
        ...mapMutations({
            add: 'increment'
        }),
        actionAdd() {
            this.$store.dispatch('handleAdd');
        }
    }
}
</script>   